Prelab

·        I2C’s default address is 0x52, which is #82 or 0101001b.

·        Since the robot needs 2 Time of Flight sensor, we need to enable them to run in parallel. But they have the same hardware address. The solution to this is to turn off one of them first by set the XSHUT pin(which is ) to low. Then change the address of the other one. Finally, turn the first sensor back ON.

·        Sketch of my wiring:

o   A diagram of a circuit board

Description automatically generated

o   The QWIIC’s 4 wires are in turn: red 3.3V, black GND, blue SDA, orange SCL, as the sketch shown.

 

 

Lab

1.     Screenshot of Artemis scanning for I2C device (and discussion on I2C address)

o   A screenshot of a computer

Description automatically generated

o   0x 29 is the only address detected.

 

2.     Contrast between different max-range modes

o   Short distance mode (1.3 m)

§  Pros: has higher accuracy, needs lower time budget which provides higher sampling rate; all of which are significant for the fast robot.

§  Cons: shorter detection range; shouldn’t be an issue since the robot is able to change direction in 1.3 M distances.

o   Long distance mode (4 m)

§  Pros: larger detection range

§  Cons: higher repeatability error, each single measurement takes more time budget; fast robot should avoid this as it needs to move in high speeds, and not capable of errors.

o   Middle distance mode is removed from the command library.

o   Guess: relative to the room and objects in the room, my robot is small and fast, even small errors may make it stuck by obstacles, so the short distance mode with higher accuracy and less errors would work better in my robot.

3.     Test the chosen mode

o   A white background with black text

Description automatically generated with medium confidence

o   Test result:

§  Using 2 sensors, set sensor 1 to short mode, and the other one uses long mode; put both of them 16 millimeters height from the table, observe and compare their data, I found that the one using short mode in deed have higher repeatability and accuracy.

 

4.     2 ToF Sensors work in parallel

 

o   A screenshot of a computer

Description automatically generated

 

o   Implementation:

§  As discussed in the prelab section, in the setup function, I added:

§  A screen shot of a computer code

Description automatically generated

o   Result verification:

§  As the serial monitor shown above, the 2 ToF Sensors are working in parallel and are able to read data simultaneously, measuring distance from different direction.

 

5.     Keep Artemis busy by printing time

o   Implementation:

§  A white background with black text

Description automatically generated

o   Approach:

§  To make Artemis print time when there’s no any available data, I modified the example code, called the checkForDataReady() function on ToF sensor2 in the while loop’s condition so the while loop only continues when neither of the sensor have data ready. The while loop body is printing time, as expected.

 

o   A screen shot of a computer

Description automatically generated

o   Observation:

§  The Artemis speed is 5.56 milliseconds per loop, and that of ToF measurements is 106 milliseconds per reading.

o   Conclusion:

§  As the Serial monitor shows, most of the lines are time, which means clock speed of Artemis is much faster than speed of ToF sensor. The measurement time used by ToF sensors are the main constrain to our speed.

6.     T10 Sending Time of Flight data with time stamps through Bluetooth.

o   A screenshot of a computer

Description automatically generated

o   Interpretation:

§  In the printing of the serial monitor: ‘end’ represents that the string parsing of the ToF data are ended successfully, which is followed by the time stamp and ToF data. The number after the data is the number of the data sent from the board; the screenshot represents the transmission of 8 ToF data are transmitted successfully.